*********************************************************************************
/*    Create scatter plot of Deterrence effect/intitial Revenue, by income		*/
*********************************************************************************

* File paths
local datapath "${mvpf_audits}/data/cleaned" 
local datafolder "${mvpf_audits}/data/outside" 
local graphpath "${graphpath}" 

* Version of fig to produce 
global version  ${version} // paper or slides

* Other formatting
if "${version}" == "slides" {
	global title "title(" ", size(vhuge))"
	global img wmf
	graph set window fontface "Arial"
	global title "title(" ", size(vhuge))"
	global axis_size "" //xsize(6.5) ysize(4)" // makes figure wider
}

else if "${version}" == "paper" {
	global title "title("")"
	global img pdf
	graph set window fontface "LMRoman10-Regular"
	global title " "
	global axis_size " " // makes figure wider
}

use "${mvpf_audits}/data/figures_rep/figure_6a_ap15.dta", clear

if "${version}" == "paper" {
*preserve
	* Cap y-axis
	local vars "determult_dis_h determult_dis_l determult_dis determult99_dis_h determult99_dis_l determult99_dis"
		foreach var of local vars {
			replace `var' = 20 if `var'>20
			replace `var' = -5 if `var'<-5
		}

	* plot deterrence multipliers by TPI decile - winsorized and unwinsorized
		twoway  (rcap determult_dis_h determult_dis_l xaxis2, lc(gs9)) ///
				(scatter determult_dis xaxis2, mc(gs9) ms(Oh)) ///
				(scatter determult99_dis xaxis, mc(gs4) ms(O)) ///
				(rcap determult99_dis_h determult99_dis_l xaxis, lc(gs4)) ///
				, ///
				yline(0, lw(thin) lp(solid) lc(gs11)) ///
				yline(3.175, lw(thin) lp(dash) lc(gs11)) ///
				xtitle("TPI Decile") ytitle("Deterrence / Audit Revenue") ///
				xlabel(1(1)12 , valuelabel  nogrid) xscale(r(1 12)) ///
				ylab(-5 "<-5" 0 "0" 5 "5" 10 "10" 15 "15" 20 "20+", nogrid) yscale(r(-5 20)) ///
				legend(off) ///
				${title} ${axis_size}	
	graph export "`graphpath'/coeffplot_detmult_tpi_unwinsorized.wmf", as(wmf) replace

	* plot deterrence multipliers by TPI decile - winsorized only
		twoway  (scatter determult99_dis xaxis, mc(gs4) ms(O)) ///
				(rcap determult99_dis_h determult99_dis_l xaxis, lc(gs4)) ///
				, ///
				yline(0, lw(thin) lp(solid) lc(gs11)) ///
				yline(3.175, lw(thin) lp(dash) lc(gs11)) ///
				xtitle("TPI Decile") ytitle("Deterrence / Audit Revenue") ///
				xlabel(1(1)12 , valuelabel  nogrid) xscale(r(1 12)) ///
				ylab(-5 "<-5" 0 "0" 5 "5" 10 "10" 15 "15", nogrid) yscale(r(-5 15)) ///
				legend(off) ///
				${title} ${axis_size}	
	graph export "`graphpath'/coeffplot_detmult_tpi.wmf", as(wmf) replace
}

if "${version}" == "slides" {
preserve
	* Cap y-axis
	local vars "determult_dis_h determult_dis_l determult_dis determult99_dis_h determult99_dis_l determult99_dis"
		foreach var of local vars {
			replace `var' = 15 if `var'>15
			replace `var' = -5 if `var'<-5
		}

	* plot deterrence multipliers by TPI decile - winsorized only
		twoway  (scatter determult99_dis xaxis, mc(gs4) ms(O)) ///
				(rcap determult99_dis_h determult99_dis_l xaxis, lc(gs4)) ///
				, ///
				yline(0, lw(thin) lp(solid) lc(gs11)) ///
				yline(3.175, lw(thin) lp(dash) lc(gs11)) ///
				xtitle("TPI Decile") ytitle("Deterrence / Audit Revenue") ///
				xlabel(1(1)12 , valuelabel  nogrid labsize(3.5)) xscale(r(0.5 12.5)) ///
				ylab(-5(5)15, nogrid) yscale(r(-5 15)) ///
				legend(off) ///
				${title} ${axis_size}	
	graph export "`graphpath'/coeffplot_detmult_tpi.wmf", as(wmf) replace
restore	
}	

